package com.fr.data.condition;

import com.fr.base.core.BaseCoreUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.privilege.authority.Authority;
import com.fr.report.script.Calculator;

public class PrivilegeCondition extends AbstractCondition
{
  public static final String XML_TAG = "PCondition";
  private static final String DELIMITER = ",";
  private Authority[] authorities;

  public PrivilegeCondition()
  {
    this(new Authority[0]);
  }

  public PrivilegeCondition(Authority[] paramArrayOfAuthority)
  {
    this.authorities = paramArrayOfAuthority;
  }

  public Authority[] getAuthoritys()
  {
    return this.authorities;
  }

  public void setAuthoritys(Authority[] paramArrayOfAuthority)
  {
    this.authorities = paramArrayOfAuthority;
  }

  public boolean eval(Object paramObject, Calculator paramCalculator)
  {
    return false;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    super.readXML(paramXMLableReader);
    if (paramXMLableReader.isChildNode())
    {
      String str1 = paramXMLableReader.getTagName();
      if (str1.equals("PCondition"))
      {
        String str2;
        if ((str2 = paramXMLableReader.getAttr("names")) != null)
        {
          String[] arrayOfString = str2.split(",");
          Authority[] arrayOfAuthority = new Authority[arrayOfString.length];
          for (int i = 0; i < arrayOfString.length; ++i)
            arrayOfAuthority[i] = new Authority(arrayOfString[i]);
          setAuthoritys(arrayOfAuthority);
        }
      }
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    super.writeXML(paramXMLPrintWriter);
    if (this.authorities.length != 0)
    {
      String[] arrayOfString = new String[this.authorities.length];
      for (int i = 0; i < this.authorities.length; ++i)
        arrayOfString[i] = this.authorities[i].getName();
      paramXMLPrintWriter.startTAG("PCondition").attr("names", BaseCoreUtils.join(arrayOfString, ",")).end();
    }
  }
}